package com.cn.service.EmployeeSevice;

/**
 * @ClassName EmployService
 * @Description TODO
 * @Author yujiajing
 * @Date 2022/10/12 10:15
 * @Version 1.0
 */

import com.cn.Mapper.enployeeMapper.EmployeeMapper;
import com.cn.entity.enployee.Employee;
import com.cn.util.SqlsesstionUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 关于雇员的所有服务
 *
 */
@Service
public class EmployService {
    /**
     * 展示所有雇员信息
     */
    public  void showEmployee(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        EmployeeMapper enployeeMapper=sqlSession.getMapper(EmployeeMapper.class);
        List<Employee> employeeList=enployeeMapper.showEmployee();
        System.out.println(employeeList.toString());
    }

    /**
     * 根据工号解雇员工
     */
    public void fireEmployee(String employ_id){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        EmployeeMapper enployeeMapper=sqlSession.getMapper(EmployeeMapper.class);
        enployeeMapper.deleteEmployee(employ_id);
        System.out.println("解雇成功!");
    }

    /**
     * 招聘雇员
     */
    public  void employEmployee() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        EmployeeMapper enployeeMapper = sqlSession.getMapper(EmployeeMapper.class);
        Employee employee = new Employee("2", "阿七", "翠园店", "运营部");
        enployeeMapper.addEmployee(employee);
    }

    /**
     * 雇员换店
     */
    public void updateEmployeeForShop(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        EmployeeMapper enployeeMapper=sqlSession.getMapper(EmployeeMapper.class);
        enployeeMapper.updateEmployeeForShop("北港","1");
    }

    /**
     * 雇员换部门
     */
    public void updateEmployeeForDpepart(){
        SqlSession sqlSession= SqlsesstionUtil.getSqlSession();
        EmployeeMapper enployeeMapper=sqlSession.getMapper(EmployeeMapper.class);
        enployeeMapper.updateEmployeeForDepart("前台","1");
    }

    /**
     * 考勤奖惩制度
     * ps:根据员工的出勤情况决定奖惩
     */
    public void R_P_forAttendanceService(){
        //
    };

}
